/*
 * tab_watch.h
 *
 *  Created on: 13.06.2013
 *      Author: SpirTanol
 */

#ifndef TAB_WATCH_H_
#define TAB_WATCH_H_

#include "events/data_event_listener.h"

// QT
#include <QSplitter>

class QLabel;
class QPushButton;
class QProgressBar;

class TableProtocol;
class ProtocolEvent;
class WatchPlot;
class TempPlot;

class WatchDataPacket;
class ConfigPacket;

class MainWindow;

class TabWatch : public QSplitter, public DataEventListener
{
	Q_OBJECT

	QLabel *oLabelCrash;
	QLabel *oLabelTemp;
	QLabel *oLabelEngine;
	QLabel *oLabelIn1;
	QLabel *oLabelIn2;
	QLabel *oLabelPowerOut;
	QLabel *oLabelAppendOut;
	QLabel *oLabelRT100State;

	QPushButton *oBtnForward;
	QPushButton *oBtnBack;
	QPushButton *oBtnStop;
	QPushButton *oBtnAppendOut;

	QLabel *oLabelWorkTime;
	QLabel *oLabelTime;

	 // Счётчик подсчёта количества пусков двигателя
	QLabel *oLabelStartCounter;

	TableProtocol *oTableProtocol;

	WatchPlot *oWatchPlot;
	TempPlot *oTempPlot;

	MainWindow *oMainWindow;

	int oInput1F;
	int oInput2F;
	bool oWetProtect;
	bool oRT100Protect;
	bool oTempProtect;

	bool oRemoteControl;

public:
	TabWatch(MainWindow *mainWindow, QVector<ProtocolEvent*> *protocol, QWidget *parent = 0);
	~TabWatch();

	void onDataEvent(const DataEvent *e); // [virtual]

	void updateProtocol();

	inline const WatchPlot *watchPlot() const { return oWatchPlot; }
	inline const TempPlot *tempPlot() const { return oTempPlot; }

	void setPlotInterval(uint interval);

private:
	void updateData(const WatchDataPacket *data);
	void updateConfig(const ConfigPacket *config);

private slots:
	void onBtnAppendOutClicked();
	void onBtnEngineCommandClicked();

};

#endif /* TAB_WATCH_H_ */
